<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'编辑科目'}"></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "270">
        <div class="analyItem">
            <p class="analyItemTit tx-center">科目</p>
            <div class="analyItemCon">
                <p class="col-md-12">
                    <span v-if="type === 1">{{leftInfo.name}}</span>
                    <input type="text" placeholder="请输入科目" style="width: 200px;" v-if="type === 2" v-model="editProject">
                </p>
                <div class="dis-il-block iconbox">
                    <img src="https://tapp.rxjy.com/common/static/images/png/edit_img.png" class="edit_img" v-if="type === 1" @click="type = 2;editProject = leftInfo.name">
                    <img src="https://tapp.rxjy.com/common/static/images/ico/save_img.png"  class="save_img" v-if="type === 2" @click="updateFineStandard()">
                    <img src="https://tapp.rxjy.com/common/static/images/ico/goback_img.png"  class="goback_img" v-if="type === 2" @click="type = 1">
                </div>
            </div>

        </div>
        <!-- <div class="analyItem">
            <p class="analyItemTit tx-center">类型</p>
            <div class="analyItemCon">
                <p class="col-md-12"><span>{{leftInfo.parentName}}</span></p>
            </div>
        </div>
        <div class="analyItem">
            <p class="analyItemTit tx-center">状态</p>
            <div class="analyItemCon">
                <p class="col-md-12"><span>{{leftInfo.del_flag === 0? '开启' : '关闭'}}</span></p>
            </div>
        </div> -->
    </div>
    <div class="layerRtb-footer">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                <!-- <div class="tx-center pt10 pb10">
                    <input type="button" class="uiBtn-normal uiBtn-blue" value="提交">
                </div> -->
            </div>
        </div>
    </div>
</div>
</template>
<script>
import { mapMutations, mapGetters } from 'vuex'
import { updateFineStandard } from '../../Resources/Api/index'
export default {
    data () {
        return {
            type: 1, // 图标显示
            editProject: '' // 编辑科目
        }
    },
    computed: {
        ...mapGetters(['leftInfo', 'updatePlate'])
    },
    created () {
        this.editProject = this.leftInfo.name
    },
    methods: {
        ...mapMutations({
            setUpDatePlate: `SET_UPDATE_PLATE`
        }),
        // 编辑科目
        updateFineStandard () {
            let parms = {
                fineStandard: {
                    typeId: this.leftInfo.id,
                    name: this.editProject
                }
            }
            updateFineStandard(parms).then(results => {
                if (results.data.StatusCode === 1) {
                    this.$message('编辑科目成功')
                    this.editProject = this.leftInfo.name
                    this.setUpDatePlate()
                } else {
                    this.$message(results.data.StatusMsg)
                }
            }).catch(error => {
                console.log(error)
            })
        }
    }
}
</script>
